Providing some additional details may be relevant to solving the problem. There are several models of iMac G5. Here's a list of all iMac models. Which specific model do you have?
http://www.everymac.com/systems/apple/imac/index-imac.html
Also, what version of Mac OS X does it run? You can select About This Mac from the Apple menu to get details about your system.
You do not need an Apple Airport Base Station. But settings on your wireless router does make a difference. For example, the last iMac G5 model (from 2005) has only 802.11b and g wireless, not 802.11n (unless you use a third-party add-on). Make sure your wireless router is not set for 802.11n only.
As a test, place the iMac close enough to your router so that you can connect it using an Ethernet cable. Do you get an Internet connection? If so, select Software Update from the Apple menu to confirm you are running the latest possible system version for your release of Mac OS X. If there's an update, try the wireless connection again after applying update.